package com.design.strategy.pay;

import java.util.HashMap;
import java.util.Map;
/**
 * 支付管理策略
 * @Author:         cong zhi
 * @CreateDate:     2021/4/4 15:17
 * @UpdateUser:     cong zhi
 * @UpdateDate:     2021/4/4 15:17
 * @UpdateRemark:   修改内容
 * @Version:        1.0
 */
public class PayStrategy {


    public static final String ALI_PAY = "AliPay";

    public static final String JD_PAY = "JDPay";

    public static final String WECHAT_PAY = "WechatPay";

    public static final String UNION_PAY = "union_pay";

    public static final String DEFAULT_PAY = ALI_PAY;

    private static Map<String, CommonPay> strategy = new HashMap<>();

    static {
        strategy.put(ALI_PAY, new AliPay());
        strategy.put(JD_PAY, new JDPay());
        strategy.put(WECHAT_PAY, new WechatPay());
        strategy.put(UNION_PAY, new UnionPay());
    }

    public static CommonPay get(String payKey) {
        if (!strategy.containsKey(payKey)) {
            return strategy.get(DEFAULT_PAY);
        }
        return strategy.get(payKey);
    }

}
